/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package model;

import java.io.Serializable;
import javax.annotation.ManagedBean;
import javax.enterprise.context.SessionScoped;
import javax.faces.application.FacesMessage;
import javax.faces.context.FacesContext;
import javax.inject.Named;
import javax.servlet.http.HttpSession;

/**
 *
 * @author eduardo

@ManagedBean
@SessionScoped
@Named("login")
public class login implements Serializable {

    private static final long serialVersionUID = 1L;
    private String username;
    private String password;

    public String getUsername() {
        return username;
    }

    public void setUsername(String name) {
        this.username = name;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String validateLogin() {
        if (username.equals(password)) {
            FacesContext.getCurrentInstance().getExternalContext().getSessionMap().put("user", username);
            FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_INFO, "", "Usuário logado com sucesso!"));

        }
        return "index";
    }

    public String logout() {
        FacesContext.getCurrentInstance().getExternalContext().getSessionMap().put("user", null);
        FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_WARN, "", "Usuário deslogado com sucesso!"));
        return "index";
    }
}
 */